﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppSocketService.DeviceRunStatusService;
using BCGPSCommon;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BCGPSRESTful.Controllers.Page.DeviceRunStatus
{
    /// <summary>
    /// 设备运行状态  -- 系统功能
    /// </summary>
    [ApiExplorerSettings(GroupName = "SystemAccount")]
    [Route("api/[controller]")]
    [ApiController]
    public class DeviceRunStatusController : PageBaseController
    {
        private readonly IDeviceRunStatusService deviceRunStatusService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="deviceRunStatusService"></param>
        public DeviceRunStatusController(IDeviceRunStatusService deviceRunStatusService)
        {
            this.deviceRunStatusService = deviceRunStatusService;
        }

        /// <summary>
        /// 查询设备运行状态
        /// </summary>
        /// <param name="imei"></param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="desc">是否倒序</param>
        /// <param name="index">页码</param>
        /// <param name="size">记录数</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<AppSocketModel.DeviceRunStatus>), 200)]
        public PageableList<AppSocketModel.DeviceRunStatus> QueryListPage(string imei,DateTime? start,DateTime? end,bool? desc = false ,int? index = 0,int? size=20)
        { 
            if (!start.HasValue)
                start = DateTime.Today;
            if (!end.HasValue)
                end = DateTime.Now;

            return deviceRunStatusService.GetList(imei, start.Value, end.Value, desc.Value, index.Value, size.Value);
        } 
    }
}